package com.dog.basics.api.controller.mtkj;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.api.mtkj.ApiGoodsEvaluateAddDto;
import com.dog.basics.bean.dto.api.mtkj.ApiGoodsEvaluateFromDto;
import com.dog.basics.bean.vo.api.mtkj.ApiGoodsEvaluateVo;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.security.annotation.Inner;
import com.dog.basics.security.util.SecurityUtils;
import com.dog.basics.service.mtkj.IMtGoodsEvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 商品评价表 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-11-09
 */
@RestController
@RequestMapping("/api/goods/evaluate")
@Api(value = "用户商品评价模块", tags = SwaggerConstants.API_ALL)
@AllArgsConstructor
public class MtGoodsEvaluateController {
    private final IMtGoodsEvaluateService mtGoodsEvaluateService;

    /**
     * @Description: 获取我的商品评价
     * @Param: CashWithdrawalAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/29  0027
     */
    @ApiOperation(value = "获取我的商品评价", notes = "获取我的商品评价", tags = SwaggerConstants.API_SHOPPINGORDE)
    @GetMapping("/getMyApiPageList")
    public R<IPage<ApiGoodsEvaluateVo>> getMyApiPageList(PageParam page, ApiGoodsEvaluateFromDto obj) {
        obj.setUserId(SecurityUtils.getUser().getUserId());
        return R.ok(mtGoodsEvaluateService.getApiPageList(page, obj));
    }

    /**
     * @Description: 获取评价列表
     * @Param: CashWithdrawalAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/05/29  0027
     */
    @ApiOperation(value = "获取评价列表", notes = "获取评价列表", tags = SwaggerConstants.API_SHOPPINGORDE)
    @GetMapping
    @Inner
    public R<IPage<ApiGoodsEvaluateVo>> getApiPageList(PageParam page, ApiGoodsEvaluateFromDto obj) {
        return R.ok(mtGoodsEvaluateService.getApiPageList(page, obj));
    }

    /**
     * @Description: 新增我的商品评价
     * @Param: GoodsEvaluateAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @PostMapping
    @ApiOperation(value = "新增我的商品评价", notes = "新增我的商品评价", tags = SwaggerConstants.API_ORDERPJ)
    public R<Boolean> saveObj(@Valid @RequestBody ApiGoodsEvaluateAddDto obj) {
        return R.ok(mtGoodsEvaluateService.saveObj(obj));
    }

    /**
     * @Description: 删除我的商品评价
     * @Param: id
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除我的商品评价", notes = "删除我的商品评价", tags = SwaggerConstants.API_ORDERPJ)
    @ApiImplicitParam(name = "id", value = "标识ID", dataType = "Long", required = true)
    public R<Boolean> delAddress(@PathVariable("id") Long id) {
        return R.ok(mtGoodsEvaluateService.deleteObj(id));
    }
}
